import { Http } from '@/common/myAxios'
import {setToken} from '@/middleware/validateInfo'
import config from '@/config'
/**
 * .验证登录账号
 * @param {*} oParams
 */
export const login = (oParams = {}) => {
  return Http('/login.json', oParams, { method: 'post' }).then(loginResult => {
    if (loginResult.result !== 1) {
      setToken()
      return {}
    }
    setToken(loginResult.token, config.wxStorage.EXPIRETIME)
    return loginResult
  })
}
// 短信登录账号
export const smsLogin = (oParams = {}) => {
  return Http('/smsLogin.json', oParams, { method: 'post' }).then(loginResult => {
    if (loginResult.result !== 1) {
      setToken()
      return {}
    }
    setToken(loginResult.token, config.wxStorage.EXPIRETIME)
    return loginResult
  })
}
/**
 * 2.提交账号基础信息
 * @param {*} oParams
 */
export const updateAccountInfo = (oParams = {}) => Http('/updateAccountInfo.json', oParams, { method: 'post' })
/**
 * 获取账号基础信息
 * @param {*} oParams
 */
export const getAccountInfo = (oParams = {}) => Http('/getAccountInfo.json', oParams, { method: 'post' })
/**
 * 6.修改账号密码
 * @param {*} oParams
 */
export const updateAccountPwd = (oParams = {}) => Http('/updateAccountPwd.json', oParams)
/**
 * 创建社保账号
 * @param {*} oParams
 */
export const createAccount = (oParams = {}) => Http('/createAccount.json', oParams)
